Skip to content

Run Vitest tests through neotest - #18

Merged
SimonKimDev merged 2 commits into
mainfrom
simonk/dev/neotest-vitest
Oct 19, 2026
Merged

SimonKimDev merged 2 commits into
mainfrom
simonk/dev/neotest-vitest

Conversation

@SimonKimDev

Copy link
Copy Markdown
Owner

The frontend (devel-frontend, Vitest 5) had no neotest adapter, so <leader>Tr / <leader>TF / <leader>Ts found nothing in .test.ts(x) files. I missed this in #9.

Adding neotest-vitest alone isn't enough on Windows. Each workaround below was a failure I reproduced against devel-frontend:

Problem on Windows Workaround in lazy/testing.lua
Runs node_modules/.bin/vitest, a shell script Windows can't start vitestCommand returns vitest.cmd
Every test shows failed although Vitest passed: report uses C:/…, neotest IDs use C:\… (marilari88/neotest-vitest#90, unmerged #74) normalise result paths
From a monorepo root (Neovim started in Devel), IDs mix C:/…\src\… and match nothing root() returns Windows paths
Tests using Vitest globals fail (test is not defined): config lookup uses a {vite,vitest}.config.* brace glob that Windows glob() doesn't expand, so Vitest runs from the wrong dir without vite.config.ts cwd = nearest package.json dir
.tsx files show no tests: neotest parses in a -u NONE child that never registers nvim-treesitter's typescriptreact → tsx alias (nvim-neotest/neotest#630, #631; broke with treesitter main) add nvim-treesitter to the child's runtimepath, which makes neotest source its plugin/filetypes.lua

All Windows-only, commented with the upstream issues, and removable once those land.

Tested with Neovim 0.12.6 against devel-frontend, starting Neovim in both Devel and Devel\devel-frontend:

  • readingTime.test.ts 3/3 passed; AppRoutes.test.tsx 9/9 passed (was 0 found)
  • a temporary test with one failing assertion reported 1 passed / 1 failed with the assertion error (file removed afterwards; Devel's git status unchanged)
  • nearest-test run: 1 passed, the other 2 not run
  • smoke test now checks every language has a neotest adapter; fresh smoke run passes

Independent of #17.

The frontend's Vitest tests had no neotest adapter, so the <leader>T
maps found nothing in .test.ts/.tsx files. Add neotest-vitest, with
Windows workarounds verified against devel-frontend:

- run node_modules/.bin/vitest.cmd; the extensionless script can't be
  started on Windows
- return Windows paths from root() and in parsed results; mixed C:/ and
  C:\ paths meant tests weren't found from a monorepo root and every
  result read as failed (marilari88/neotest-vitest#90, unmerged #74)
- run from the package directory so Vitest loads vite.config.ts
  (globals etc.); the plugin's brace glob doesn't expand on Windows

Also add nvim-treesitter to neotest's -u NONE parsing subprocess so it
gets filetype aliases (typescriptreact -> tsx); without it .tsx test
files show no tests (nvim-neotest/neotest#630, #631).

The smoke test checks every language has a neotest adapter.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 90315f97-7c82-4bc1-9bf1-2f8460782554
@SimonKimDev
SimonKimDev marked this pull request as ready for review October 19, 2026 05:18
…x-nvim-config-bugs

# Conflicts:
#	tests/smoke.lua
@SimonKimDev
SimonKimDev merged commit 2976d07 into main Oct 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant